/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.fimuni.pa165.backendderby.services;

import cz.fimuni.pa165.backendderby.dao.EmployeeDAO;
import cz.fimuni.pa165.backendderby.entities.Company;
import cz.fimuni.pa165.backendderby.entities.Employee;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Michal Polkorab
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeDAO empDao;

    public void setEmpDao(EmployeeDAO empDao) {
        this.empDao = empDao;
    }

    @Transactional
    public void createEmployee(Employee emp) {

        empDao.create(emp);

    }

    @Transactional
    public boolean updateEmployee(Employee emp) {

        return empDao.update(emp);

    }

    @Transactional
    public void deleteEmployee(Employee emp) {

        empDao.remove(emp);

    }

    @Transactional
    public Employee get(Long id) {

        Employee emp = empDao.get(id);
        return emp;

    }

    @Transactional
    public List<Employee> findByName(String surname) {

        List<Employee> emp = empDao.findByName(surname);
        return emp;

    }

    @Transactional
    public List<Employee> findByCompany(Company company) {

        List<Employee> emp = empDao.findByCompany(company);
        return emp;

    }

    public List<Employee> getAllEmployees() {
        List<Employee> emp = empDao.getAllEmployees();
        return emp;
    }

    public List<Employee> findByUsername(String username) {
        List<Employee> emp = empDao.findByUsername(username);
        return emp;
    }
}
